from django.test import TestCase
from django.test.client import Client
from events.models import Event, Participant
from django_undo.utils import save_undo, do_undo

class UndoTest(TestCase):
    def setUp(self):
        pass

    def tearDown(self):
        pass

    def test_update_and_undo(self):
        """
        Test undoing a model update
        """
        event = Event.objects.get(id=1)
        name = event.name
        capacity = event.capacity

        print self.client.session
        self.client.session['mytest'] = 'hejsa'
        print self.client.session
        #print self.client.session['message']

        # save an undo operation
        url = '/myredirecturl/'
        id = save_undo(self.client, event, redirect_to=url)
        #print 'id %s' % id,

        # update the event object with altered values
        event.name = 'some other name'
        event.capacity = capacity + 1
        event.save()

        # assert the model has been updated with new values
        event = Event.objects.get(id=1)
        self.assertNotEqual(name, event.name)
        self.assertNotEqual(capacity, event.capacity)

        #new_url = do_undo(response.request, id)

    def test_delete_and_undo(self):
        pass